<template>
  <el-button
    :size="dataModelBase.buttonSize"
    :type="dataModelBase.buttonType"
    :plain="dataModelBase.buttonPlain"
    :round="dataModelBase.buttonRound"
    :circle="dataModelBase.buttonCircle"
    :icon="dataModelBase.buttonIcon"
    @click="click"
  >
    {{ dataModelBase.buttonName }}
  </el-button>
</template>

<script>
import widget from '@/mixins/widget'

export default {
  mixins: [widget],

  methods: {
    click() {
      if (this.dataModelBase.optType === 1) {
        if (this.flag === 'Generate') {
          this.openLink()
        }
      } else {
        this.$emit('click')
      }
    },

    openLink() {
      let url = this.dataModelData.openUrl + '?'
      for (const key in this.interactParams) {
        url = `${url}${key}=${this.interactParams[key]}&`
      }
      url = url.substr(0, url.length - 1)
      window.open(url)
    }
  }
}
</script>

<style lang="scss" scoped>
.el-button {
  display: flex !important;
  align-items: center;
  /deep/ i {
    font-size: 12px;
    margin-right: 6px !important;
  }
}
</style>
